package com.appspot.etao.model;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.appspot.etao.Constant;
import com.appspot.etao.util.StringUtil;
import com.taobao.top.domain.Shop;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ShopModel extends BaseModel {

	private static final long serialVersionUID = -8815963688680278239L;
	
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
    
    /** 店铺编号 */
    @Persistent
	private String sid;
    
    /** 店铺所属的类目编号 */
    @Persistent
	private String cid;
    
    /** 卖家昵称 */
    @Persistent
	private String nick;
    
    /** 店铺标题 */
    @Persistent
	private String title;
    
//    /** 店铺描述 */
//    @Persistent
//	private String desc;
//    
//    /** 店铺公告 */
//    @Persistent
//	private String bulletin;
    
    /** 店标地址 */
    @Persistent
	private String picPath;
    
    @Persistent
	private Date created;
    
    @Persistent
	private Date modified;
	
	private Shop shop;
	
	public ShopModel() {
		
	}
	
	public ShopModel(Shop shop) {
		setShop(shop);
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSid() {
		return sid;
	}

	public void setSid(String sid) {
		this.sid = sid;
	}

	public String getCid() {
		return cid;
	}

	public void setCid(String cid) {
		this.cid = cid;
	}

	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

//	public String getDesc() {
//		return desc;
//	}
//
//	public void setDesc(String desc) {
//		this.desc = desc;
//	}
//
//	public String getBulletin() {
//		return bulletin;
//	}
//
//	public void setBulletin(String bulletin) {
//		this.bulletin = bulletin;
//	}

	public String getPicPath() {
		return picPath;
	}

	public void setPicPath(String picPath) {
		this.picPath = picPath;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Date getModified() {
		return modified;
	}

	public void setModified(Date modified) {
		this.modified = modified;
	}

	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
		
		this.sid = StringUtil.cut(shop.getSid().toString());
		this.cid = StringUtil.cut(shop.getCid().toString());
		this.nick = StringUtil.cut(shop.getSellerNick());
		this.title = StringUtil.cut(shop.getTitle());
//		this.desc = StringUtil.cut(shop.getDescription());
//		this.bulletin = StringUtil.cut(shop.getBulletin());
		this.picPath = StringUtil.cut(shop.getLogoUrl());
		this.created = shop.getCreated();
		this.modified = shop.getModified();
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer("");
		sb.append("[");
		sb.append(sid);
		sb.append(",");
		sb.append(cid);
		sb.append(",");
		sb.append(nick);
		sb.append(",");
		sb.append(title);
		sb.append(",");
//		sb.append(desc);
//		sb.append(",");
//		sb.append(bulletin);
//		sb.append(",");
		sb.append(picPath);
		sb.append(",");
		sb.append(Constant.FORMATER.format(created));
		sb.append(",");
		sb.append(Constant.FORMATER.format(modified));
		sb.append("]");

		return sb.toString();
		
	}

}
